/* funcao de redirecionamento da pagina */
function goURL(url) {
    
    document.location = url;
    
}

/* funcao que chama uma acao do struts */
function callAction(method, params, frm) {
    
    if ((!Util.isEmpty(method)) && (Util.isEmpty(params))) {
            
        goURL(method + ".do");
            
    } else if (Util.isEmpty(frm)) {
            
        goURL(method + ".do?method=" + params);
            
    } else {
        
        document.forms[frm].action = method + ".do";
        document.forms[frm].method.value = params;
        document.forms[frm].submit();
            
    }
    
}

/* chamada de um popup */
function callPop(popURL, frName, pWidth, pHeight) {
    
    var frm     = parent.document.forms["frPOP"];
    var popName = (!Util.isEmpty(frName))?(frName+"P"):"wopen";
      
    var vWidth  = (!Util.isEmpty(pWidth))?pWidth:600;
    var vHeight = (!Util.isEmpty(pHeight))?pHeight:300;
    
    frm.target        = popName;
    frm.vPagina.value = popURL;
    
    win = window.open("about:blank", popName, "dialog=yes, modal=yes, scrollbars=yes, width=" + vWidth + "px, height=" + vHeight + "px");
    
    lt = (screen.width/2) - (vWidth/2);
    tp = (screen.height/2) - (vHeight/2);
    
    win.moveTo(lt, tp);
    win.focus();
    
    frm.submit();
    
    return false;
    
}

function callPopClose(frName) {
    
    if (!Util.isEmpty(frName)) {
        
        if (frName!="wopen") {
        
            vName = frName.substr(0,frName.length-1);
            
            if (vName=="noFrame") {
        
                parent.document.location.reload();
            
            }
            
            if (vName!="noFrame") {
            
                vLocation = eval("parent." + frName);
                eval("parent.frames['" + vName  + "'].document.location.replace('" + vLocation + "')");
                
            }
                
        }
        
    }
    
    return false;
    
}
function limitarTextArea(obj, max, divProgresso) {
    ancho = 300;
    if (obj.value.length < max) {
        divProgresso.style.backgroundColor = "#FFFFFF";
        divProgresso.style.backgroundImage = "url('/PedigreePetstore/img/progress.png')";
        divProgresso.style.color = "#000000";
        var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/max);
        divProgresso.style.backgroundPosition = "-"+pos+"px 0px";
    } else {
        divProgresso.style.backgroundColor = "#CC0000";
        divProgresso.style.backgroundImage = "url()";
        divProgresso.style.color = "#FFFFFF";
    }
    if (obj.value.length > max) {
        obj.value = obj.value.substring(0, max);
    }
    divProgresso.innerHTML = "("+obj.value.length+" / "+max+")";
}